#include <string.h>
#include "dict.h"

Dict dict_empty(void){
	Dict d;	
	d.tam=0;
	d.la = la_empty();
return d;
}


Dict dict_add(Dict d, Word w, Def f){
	Key k;
	Data dt;
	k = key_fromString(w);
	dt = data_fromString(f.s);
	d.la = la_add(d.la,k,dt);
	d.tam = (d.tam) + 1;
return d;
}

bool dict_exists(Dict d, Word w){
	bool b;
	Key k;
	k = key_fromString(w);
	b = la_exists(d.la,k);
return b;
}


Def dict_search(Dict d,Word w){
	Key k;
	Data dt;
	Def f;

		if (dict_exists(d,w) == TRUE){
		k = key_fromString(w);
		dt = la_search(d.la,k);
		strcpy(f.s,dt.s);
		}
return f;
}

Dict dict_del(Dict d, Word w){
	Key k;
	k = key_fromString(w);
	d.la = la_del(d.la,k);
	d.tam = (d.tam)-1;
return d;
}

void dict_print(Dict d){
	print_listAsoc(d.la);
}

int dict_size(Dict d){
	int n;
	n = d.tam;
return n;
}

void print_def(Def f){
	printf("%s\n", f.s);
}

Def get_def(Def f){
	scanf("%s", f.s);
	return f;
}
